package com.zj.ecology.splash

import android.content.Intent
import android.os.Bundle
import android.view.Window
import android.view.WindowManager
import android.widget.TextView
import com.zj.base.LayoutModule
import com.zj.base.base_act.BaseActivity
import com.zj.base.permission.annotations.CheekPermissions
import com.zj.base.permission.manifests.PermissionsManifest
import com.zj.base.view_injector.annotantions.IdRes
import com.zj.ecology.R
import com.zj.ecology.activity.IndexActivity
import com.zj.weather.DynamicWeatherBackground

/**
 * Created by zhaojie on 2018/7/25.
 */
@CheekPermissions(isForce = [false], value = [(PermissionsManifest.FINE_LOCATION)])
class SplashActivity : BaseActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN)
        super.onCreate(savedInstanceState)
    }

    @IdRes(R.id.splash_weatherBgView)
    private val weatherView: DynamicWeatherBackground? = null
    @IdRes(R.id.splash_tv_next)
    private val tvNext: TextView? = null;
    @IdRes(R.id.splash_tv_skip)
    private val tvSkip: TextView? = null;

    //for 0-9
    private var curDrawer = 0

    override fun isTitleBarShow(): Boolean {
        return false
    }

    override fun setTitle(): String? {
        return null
    }

    override fun getContentView(): LayoutModule {
        return LayoutModule(R.layout.activity_splash, true, false)
    }

    override fun initView() {
        weatherView?.setDrawerType(0)
    }

    override fun initListener() {
        tvNext?.setOnClickListener {
            curDrawer++
            weatherView?.setDrawerType(curDrawer % 9)
        }

        tvSkip?.setOnClickListener {
            startActivity(Intent(this@SplashActivity, IndexActivity::class.java))
        }
    }

    override fun onResume() {
        weatherView?.onResume()
        super.onResume()
    }

    override fun onPause() {
        weatherView?.onPause()
        super.onPause()
    }

    override fun onDestroy() {
        weatherView?.onDestroy()
        super.onDestroy()
    }
}
